import React, { Component } from 'react'

export default class Detail extends Component {
    state={
        detail:{} 
    }
    initData = ()=>{
        const {$httpReq,$api} = this
        $httpReq($api.HEALTH_DATAIL({id:this.props.match.params.id}),res=>{
                this.setState({detail:res.data})
        })
    }
    render() {
        const {detail} = this.state
        return (
            <div>
                {
                    Object.keys(detail).map(i=>{
                        if(i !== 'recentTrip'){
                            return <div key={i}>
                                        <span>{i}</span>
                                        <b>{detail[i]}</b>
                                    </div>
                        }
                        return detail.recentTrip.map((j,key)=><div style={{color:'red'}} key={key}>
                                    {
                                        Object.keys(j).map(k=><div key={k}>
                                                    <span>{k}</span>
                                                    <b>{j[k]}</b>
                                                </div>
                                        )
                                    }
                            </div>
                        )
                       
                    })
                }
            </div>
        )
    }
    componentDidMount = ()=> this.initData()
}
